#include "Frotator.h"
#include <gtc/matrix_transform.hpp>

FRotator::FRotator()
{
	Roll = 0.0f;
	Pitch = 0.0f;
	Yaw = 0.0f;

	Rotator = glm::vec3(Roll, Pitch, Yaw);
}

FRotator::FRotator(float Angle)
{
	Roll = Pitch = Yaw = Angle;

	Rotator = glm::vec3(Roll, Pitch, Yaw);
}

FRotator::FRotator(float roll, float pitch, float yaw)
{
	Roll = roll;
	Pitch = pitch;
	Yaw = yaw;

	Rotator = glm::vec3(Roll, Pitch, Yaw);
}

FRotator::~FRotator()
{
}

glm::mat4 FRotator::RotationMatrix()
{
	glm::mat4 rotationMatrix(1.0f);
	
	if (Rotator.x != 0.0f)
		rotationMatrix = glm::rotate(rotationMatrix, glm::radians(Rotator.x), glm::vec3(1.0f, 0.0f, 0.0f));
	if (Rotator.y != 0.0f)
		rotationMatrix = glm::rotate(rotationMatrix, glm::radians(Rotator.y), glm::vec3(0.0f, 1.0f, 0.0f));
	if (Rotator.z != 0.0f)
		rotationMatrix = glm::rotate(rotationMatrix, glm::radians(Rotator.z), glm::vec3(0.0f, 0.0f, 1.0f));

	return rotationMatrix;
}

FRotator FRotator::operator+=(const FRotator& R)
{
	Pitch += R.Pitch; Yaw += R.Yaw; Roll += R.Roll;

	Rotator = glm::vec3(Roll, Pitch, Yaw);
	return *this;
}
